// @ts-ignore
/* eslint-disable */
import { request } from 'umi';

/** 获取定时任务列表 GET /api/driver */
export async function queryTask(
  params: {
    // query
    /** 当前的页码 */
    current?: number;
    /** 页面的容量 */
    pageSize?: number;
  },
  options?: { [key: string]: any },
) {
  return request<API.RequestData>('/api/task', {
    method: 'GET',
    params: {
      ...params,
    },
    ...(options || {}),
  });
}

/** 更新定时任务 PUT /api/driver */
export async function updateTask(body: API.TaskItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/task', {
    method: 'PUT',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 更新定时任务状态 PUT /api/driver */
export async function updateTaskState(body: any, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/task/updateState', {
    method: 'PUT',
    requestType:'form',
    data: body,
    ...(options || {}),
  });
}


/** 添加定时任务 POST /api/driver */
export async function addTask(body: API.TaskItem, options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/task', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
    },
    data: body,
    ...(options || {}),
  });
}

/** 删除定时任务 DELETE /api/driver */
export async function removeTask(options?: { [key: string]: any }) {
  return request<Record<string, any>>('/api/task', {
    method: 'DELETE',
    ...(options || {}),
  });
}


